#ifndef LISTFILE_H_INCLUDED
#define LISTFILE_H_INCLUDED

#include <stdlib.h>
#include <stdint.h>

#include "fmap.h"
#include "reporting.h"

#define LISTFILE_ERRCODE_BASE      (8100)
#define LISTFILE_ERR_OPEN_FAILED   (LISTFILE_ERRCODE_BASE + 1)


typedef struct _listfile_t {
	int        fd;
	int        next_index;
	fwindow_t  head;
} listfile_t;


#ifdef LISTFILE_INLINE_ALL
#define LISTFILE_STATIC static
#include "listfile.c"
#else
#define LISTFILE_STATIC
int listfile_init(listfile_t * self, int fd);
int listfile_fini(listfile_t * self);
int listfile_append(listfile_t * self, const void * buffer, uint32_t size);
off_t listfile_append2(listfile_t * self, const void * buffer, uint32_t size);
int listfile_open(listfile_t * self, const char * filename);
int listfile_close(listfile_t * self);
#endif


#endif /* LISTFILE_H_INCLUDED */
